home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-25 | 4.7 KB | 152 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWPopup.h
- // Release Version: $ ODF 1 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWPOPUP_H
- #define FWPOPUP_H
-
- #ifndef FWCONTRL_H
- #include "FWContrl.h"
- #endif
-
- #ifndef FWFONT_H
- #include "FWFont.h"
- #endif
-
- #ifndef FWRUNTYP_H
- #include "FWRunTyp.h"
- #endif
-
- #ifndef FWNOTIFR_H
- #include "FWNotifr.h"
- #endif
-
- #ifndef FWSTRING_H
- #include "FWString.h"
- #endif
-
- //========================================================================================
- // Forward class declarations
- //========================================================================================
-
- class FW_CViewContext;
-
- //========================================================================================
- // Popup styles
- //========================================================================================
-
- typedef unsigned short FW_PopupMenuStyle;
-
- // Note: on Macintosh you can use variant codes defined in <controls.h>:
- // popupFixedWidth, popupVariableWidth, popupUseAddResMenu, popupUseWFont
-
- //========================================================================================
- // CLASS FW_CPopupMenu
- //========================================================================================
-
- class FW_CPopupMenu : public FW_CNativeControl
- {
- // ----- Initialization/destruction
- public:
- FW_DECLARE_CLASS
- FW_DECLARE_AUTO(FW_CPopupMenu)
-
- FW_CPopupMenu(Environment* ev,
- FW_CSuperView* container, ODID id,
- const FW_CRect& bounds,
- FW_ResourceId menuId,
- const FW_CString& label,
- short titleWidth = 0,
- short initialMenuItem = 1,
- FW_PopupMenuStyle popupVariation = 0,
- const FW_CFont& font = FW_kSystemFont12,
- long popupRefCon = 0);
-
- FW_CPopupMenu(Environment* ev);
- virtual ~FW_CPopupMenu();
-
- public:
- // ----- Inherited API
-
- // FW_CNativeControl
- virtual void ControlClicked(Environment *ev, FW_ControlValue value, ODFacet* facet);
-
- // Archiving
- static void* Create(FW_CReadableStream& stream, FW_ClassTypeConstant type);
- static void Destroy(void* object, FW_ClassTypeConstant type);
- virtual void Flatten(Environment*ev, FW_CWritableStream& stream) const;
- virtual void InitializeFromStream(Environment*ev, FW_CReadableStream& stream);
-
- // ----- New API -----
- void GetMenuString(Environment* ev, FW_CString& str) const;
- void GetMenuString(Environment* ev, short index, FW_CString& str) const;
- FW_PlatformHandle GetPlatformMenuHandle() const;
-
- protected:
- // ----- Internal use only
- virtual FW_Boolean PrivSetValue(Environment* ev, FW_ControlValue value, ODFacet* facet);
-
- private:
- void Initialize(Environment* ev, FW_ResourceId menuId,
- const FW_CString& title, short titleWidth,
- short initialMenuItem, FW_PopupMenuStyle variation,
- const FW_CFont& font, long popupRefCon);
- };
-
- //========================================================================================
- // CLASS FW_CPopupMenuNotification
- //========================================================================================
-
- class FW_CPopupMenuNotification : public FW_CControlNotification
- {
- public:
- FW_DECLARE_CLASS
-
- FW_CPopupMenuNotification(FW_CPopupMenu* popup);
- FW_CPopupMenuNotification(const FW_CPopupMenuNotification& other);
- virtual ~FW_CPopupMenuNotification();
-
- FW_CPopupMenuNotification& operator=(const FW_CPopupMenuNotification& other);
-
- void GetMenuString(Environment*ev, FW_CString& str) const;
- short GetMenuIndex(Environment*ev) const;
-
- private:
- short fMenuIndex; // index of item selected
- FW_CString fMenuString; // string of item selected
- };
-
- //========================================================================================
- // inlines
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CPopupMenu::GetMenuString
- //----------------------------------------------------------------------------------------
-
- inline void FW_CPopupMenu::GetMenuString(Environment* ev, FW_CString& str) const
- {
- GetMenuString(ev, (short)GetValue(ev), str);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPopupMenuNotification::GetMenuString
- //----------------------------------------------------------------------------------------
-
- inline void FW_CPopupMenuNotification::GetMenuString(Environment*, FW_CString& str) const
- {
- str = fMenuString;
- }
-
- inline short FW_CPopupMenuNotification::GetMenuIndex(Environment*) const
- {
- return fMenuIndex ;
- }
-
- #endif
-